<?php
namespace Myfunc\Controller;
use Think\Controller;

// 开发者：杨晓杰，
// 邮箱：2902468225@qq.com 

class CommentController extends Controller {
	private $db='comment';
	//企业的评论列表，需要企业id
	public function commentList($cpn_id,$is_verify){
		$data=M($this->db)->join('__STUDENT__ ON __COMMENT__.std_id = __STUDENT__.id')->where('cpn_id = '.$cpn_id.' and tswc_comment.is_verify = '.$is_verify)->order('comment_id desc')->field('id,comment_id,name,content,comment_time')->select();
		$data=R('Myfunc/Myfunc/pageDeal',array('data'=>$data));
        $data['is_verify']=$is_verify;
		return $data;
	}
    // 评论认证
    public function verify($comment_id,$is_verify){
        $where['comment_id']=$comment_id;
        $data['is_verify']=$is_verify;
        if(M($this->db)->where($where)->save($data))return 1;
        else return 0;
    }
    // 评论接口
    public function comment($cpn_id,$std_id,$content){
        $data['cpn_id']=$cpn_id;
        $data['std_id']=$std_id;
        $data['content']=$content;
        $data['comment_time']=date('Y-m-d H:i:s',time());
        if(M($this->db)->add($data))return 1;
        else return 0;
    }
    // 删除评论
    public function delete($comment_id){
        $where['comment_id']=$comment_id;
        if(M($this->db)->where($where)->delete())return 1;
        else return 0;
    }
}